package com.mmall.other.example.singleton;/**
 * Created with IDEA
 * Author : wangfei
 * Date :  2019/10/23
 * Time : 10:15
 * Describe :
 */

/**
 * @ClassName MySingleton
 * @Describe :
 * @Author : wangfei 
 * @Date :  2019/10/23 10:15
 */
public class MySingleton {
//	private static MySingleton instance = new MySingleton();
//
//	public static MySingleton getInstance() { return instance; } }


	private static MySingleton instance = null;


	public static synchronized MySingleton getInstance() {
	//这个方法比上面有所改进，不用每次都进行生成对象，只是第一次 //使用时生成实例，提高了效率！ if
		if ((instance==null)) {
			instance = new MySingleton();
		}
		return instance;
	}
}
